//
//  Kratos_bangdingView.m
//  gggg
//
//  Created by K on 2019/1/9.
//  Copyright © 2019 K. All rights reserved.
//

#import "Kratos_bangdingView.h"
#import "Masonry.h"
#import "Kratos_bangdingInputView.h"
#import "UIImage+kkkk_LoadBundleImage.h"

@interface Kratos_bangdingView()
///登录
@property (nonatomic,strong) UIButton *bangdingbutton;
///返回按钮就
@property (nonatomic,strong) UIButton *backbtn;
@end;




@implementation Kratos_bangdingView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self configrationInputVIew];
        [self setupQuickButtton];
        [self setupBack];
       
        
        [[NSNotificationCenter defaultCenter]addObserverForName:@"countDownend" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
            
            if  ([self.delegate respondsToSelector:@selector(Kratos_getmsgCodeClick:)])
            {
                [self.delegate Kratos_getmsgCodeClick:note.object];
            }
            
        }];
        
    }
    return self;
}

- (Kratos_bangdingInputView *)bangdingInputView
{
    if (_bangdingInputView == nil) {
        _bangdingInputView = [[Kratos_bangdingInputView alloc] init];
    }
    return _bangdingInputView;
}

- (UIButton *)bangdingbutton
{
    if (_bangdingbutton == nil)
    {
        _bangdingbutton= [[UIButton alloc]init];
        _bangdingbutton.layer.masksToBounds = YES;
        _bangdingbutton.layer.cornerRadius = 5;
        _bangdingbutton.backgroundColor = [UIColor redColor];
        _bangdingbutton.titleLabel.numberOfLines = 0;
        [_bangdingbutton.titleLabel setFont:[UIFont systemFontOfSize:13]];
        [_bangdingbutton setTitle:@"立即绑定" forState:UIControlStateNormal];
        [_bangdingbutton addTarget:self action:@selector(Kratos_bangdingClick:) forControlEvents:UIControlEventTouchUpInside];
        
        
    }
    return _bangdingbutton;
    
}

- (UIButton *)backbtn
{
    if (_backbtn == nil) {
        _backbtn = [[UIButton alloc] init];
        [_backbtn setTitle:@"返回" forState:UIControlStateNormal];
        [_backbtn setImage:[UIImage Kratos_setBundleImageName:@"backp"] forState:UIControlStateNormal];
        [_backbtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backbtn;
}

- (void)backBtnClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(Kratos_dissmissVC)]) {
        [self.delegate Kratos_dissmissVC];
    }
}



- (void)Kratos_bangdingClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(Kratos_bangdingClick:)]) {
        [self.delegate Kratos_bangdingClick:sender];
    }
}

- (void)setupBack
{
    [self addSubview:self.backbtn];
    
    [self.backbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).mas_offset(5);
        make.left.mas_equalTo(self).mas_offset(5);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
        
    }];
}

- (void)configrationInputVIew
{
    [self addSubview:self.bangdingInputView];
    [self.bangdingInputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.mas_width);
        make.top.equalTo(self).mas_offset(30);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
}

- (void)setupQuickButtton
{
    
    [self addSubview:self.bangdingbutton];
    
    [self.bangdingbutton mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(40);
        make.top.equalTo(self.bangdingInputView.mas_bottom).mas_offset(10);
    }];
    
    
}

- (void)setDelegate:(id<Kratos_bangdingViewDelegate>)delegate
{
        _delegate = delegate;
        [self Kratos_setupTitle:@"绑定手机"];
    
        
    
}

@end
